package com.example.collection;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: qijiang
 * @date: 2019/8/15 17:30
 */

@Component
public class CustomBeanPostProcessor implements BeanPostProcessor {
    @Nullable
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if(bean.getClass()==User.class){
            System.out.println("调用postProcessBeforeInitialization...");
        }
        return bean;
    }
    @Nullable
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(bean.getClass()==User.class){
            System.out.println("调用postProcessAfterInitialization...");
        }
        return bean;
    }
}
